//
//  LZGrouponUserView.m
//  laziz_Consumer
//
//  Created by xbn_iMac on 2016/12/6.
//  Copyright © 2016年 XBN. All rights reserved.
//

#import "LZGrouponUserView.h"
#import "LZGroupUser.h"
#import "UIImageView+WebCache.h"
#import "Masonry.h"

@interface LZGrouponUserView ()

@property (nonatomic, strong) UILabel *labName;
@property (nonatomic, strong) UIImageView *headImageView;
@property (nonatomic, strong) LZGroupUser *userModel;

@end

@implementation LZGrouponUserView

- (instancetype)initWithGrouponUserModel:(LZGroupUser*)model {
    self = [super initWithFrame:CGRectZero];
    if (self) {
        self.userModel = model;
        [self createSubviews];
    }
    return self;
}

- (void) createSubviews {
    // 昵称
    self.labName = [[UILabel alloc] init];
    self.labName.text = self.userModel.nickname;
    self.labName.font = [UIFont systemFontOfSize:12];
    self.labName.textColor = UIColorFromRGB(0x666666, 1);
    self.labName.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.labName];
    
    // 头像
    self.headImageView = [[UIImageView alloc] init];
    self.headImageView.layer.masksToBounds = YES;
    self.headImageView.layer.cornerRadius = 22;
    [self addSubview:self.headImageView];
    
    [self.headImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",APIBaseImageUrl,self.userModel.userPhoto]] placeholderImage:[UIImage imageNamed:@"lz_user_placehoiderImage"]];
    
    
    [self.labName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self);
        make.leading.and.trailing.equalTo(self);
    }];
    
    [self.headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self);
        make.centerX.equalTo(self);
        make.width.and.height.mas_equalTo(44);
    }];

}

- (CGSize)intrinsicContentSize {
    return CGSizeMake(0, self.labName.intrinsicContentSize.height+10+44);
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
